<?php

function smarty_block_checkperms($params, $content, &$smarty){
    $USER = JFX::registry('JFX_User');
    
    if (empty($params['section'])) {
        $smarty->trigger_error("assign: missing 'section' parameter");
        return;
    }

    if (!in_array('module', array_keys($params))) {
        $smarty->trigger_error("assign: missing 'module' parameter");
        return;
    }
    
    if(!in_array('action', array_keys($params))){
        $smarty->trigger_error("assign: missing 'action' parameter");
        return;
    };
    
    if(!in_array('status', array_keys($params))){
        $checkStatus = true;
    }else{
        $checkStatus = $params['status'];
    }
    
    if(isset($content) && $USER->checkPerms($params['section'], $params['module'], $params['action'], $checkStatus)){
        return $content;
    }else{
        return;
    }
}
